/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.ResourceBundle;

/**
 *
 * @author tanya
 */
public class ConfigurationManager {


    /**  Instance of class     */
    private static ConfigurationManager instance=null;
    private Properties linksProperties;

	public ConfigurationManager () {
		
            try {
			linksProperties = new Properties();
			ClassLoader cl = Thread.currentThread().getContextClassLoader();
			InputStream input = cl.getResourceAsStream("/bundle/config.properties");
			linksProperties.load(input);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
        
    /**
     * Create new instance of class if 'instance' is empty
     * @return ConfigurationManager instance of class
     */
    public static ConfigurationManager getInstance() {
        if(instance == null){
            instance = new ConfigurationManager();
            // Set resourceBundle attribute
        }
        return instance;
    }
    
//            /**  Properties file name     */
//    private static final String BUNDLE_NAME="config";
//    /**  Properties MAIN_PAGE key     */
//    public static final String MAIN_PAGE="MAIN_PAGE";
//    /**  Properties COUNT_PAGE key     */
//    public static final String ADMIN_PAGE="ADMIN_PAGE";
//    /**  Properties SESSION_MAX_INACTIVE_INTERVAL key     */
//    //public static final String SESSION_MAX_INACTIVE_INTERVAL="SESSION_MAX_INACTIVE_INTERVAL";
//    /**  Properties LOGIN_PAGE key     */
//    public static final String LOGIN_PAGE = "LOGIN_PAGE";
//    /**  Properties ERROR_PAGE key     */
//    public static final String ERROR_PAGE = "ERROR_PAGE";
//    /**  Instance of class     */
//    private static ConfigurationManager instance=null;
//    /**  Resource bundle object   */
//    private ResourceBundle resourceBundle;
//
//    /**
//     * Create new instance of class if 'instance' is empty
//     * @return ConfigurationManager instance of class
//     */
//    public static ConfigurationManager getInstance() {
//        if(instance == null){
//            instance = new ConfigurationManager();
//            // Set resourceBundle attribute
//            instance.resourceBundle = ResourceBundle.getBundle(BUNDLE_NAME);
//        }
//        return instance;
//    }
//    /**
//     * Return value of properties record by the key name
//     * @param key
//     * @return value of parameter by key
//     */
//    public String getProperty(String key){
//        return (String)resourceBundle.getObject(key);
//    }

    public Properties getLinksProperties() {
        return linksProperties;
    }
}
